// import {nanoid} from 'nanoid';
import request, { MockResult } from "../request";
const baseUrl = "/spd-eatonos-service";

export const auth = {
  // 获取菜单
  getMenuList(params) {
    return request({
      url: baseUrl + "/user/getAppResource",
      method: "get",
      params,
      mock: {
        useMock: true,
        data: MockResult.success({
          menuList: [
            {
              path: "/index",
            },
            {
              path: "/systemManagement",
              children: [],
            },
          ],
        }),
      },
    });
  },
  // 登录
  login(data) {
    let isAdmin = false;
    if (data.userName === "admin") {
      isAdmin = true;
    }
    return request({
      url: baseUrl + "/auth/login",
      method: "post",
      data,
      mock: {
        useMock: true,
        data: MockResult.success({
          token: "111",
          userInfo: {
            nickName: "胡栋栋",
            age: 27,
            userName: "anyaccount",
            isAdmin: isAdmin,
          },
        }),
      },
    });
  },
  // 获取用户信息
  getUserInfo(params) {
    return request({
      url: baseUrl + "/user/getUserInfo",
      method: "get",
      params,
    });
  },
};

export default auth;
